package co.yixiang.modules.bank;

import co.yixiang.api.ApiResult;
import co.yixiang.modules.pay.AppControllerUtil;
import co.yixiang.modules.pay.AppPayService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Slf4j
@RestController
@Api(value = "回调", tags = "支付:回调", description = "回调")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AppPayController extends AppControllerUtil{

    @Autowired
    private AppPayService appPayService;




    /**
     * 微信回调
     * @return
     */
    @RequestMapping(value = "/pay/weixinReturnUrl", method = {RequestMethod.POST, RequestMethod.GET})
    public void weixinPayResult(HttpServletRequest request, HttpServletResponse response)throws Exception {
        ApiResult responseData = appPayService.weixinPayResult(request);
            super.resultAjaxDataApp(response,responseData,"");
    }




    /**
     * 支付宝回调
     * @return
     */
    @RequestMapping(value = "/pay/aliyunReturn", method = {RequestMethod.POST, RequestMethod.GET})
    public void aliyunReturn(HttpServletRequest request, HttpServletResponse response) throws Exception {
            ApiResult responseData = appPayService.zhifubaoPayResult(request);
            super.resultAjaxDataApp(response,responseData,"");
    }





}
